Android Architecture blueprints TodoApp
android/architecture-samples: A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
ファイルの構造から把握したい。
fragment別にpackageしてViewModelをそこに置く。(Activityは1つ)
viewModelFactoryを作っておいて、各々のfragmentのviewModelは by でプロパティ設定できるようにしておく
data packageにsource, data型(task, result)
sourceには、default repositoryを置いて、local, remoteは別途repository を置く
Daoを定義して、その後にdatabase接続に関する具体的な処理を書く。
listの処理は、Android ReclclerView ListAdapterを使ってる
Android Data Bindingで、@BindingAdapter を使ってる
https://gyazo.com/af07fb12d32ae6b1e804c003c918911f
あとは、
if (BuildConfig.DEBUG) Timber.plant(DebugTree())
拡張関数は?
View.setupSnackBar(lifecycleOnwer, LiveData<Event<Int>>, Int)
View.showSnackBar(String, Int)
fun Fragment.setupRefreshLayout(ScrollChildSwipeRefreshLayout,View?)
fun Fragment.getViewModelFactory(): ViewModelFactory {.... return ViewModelFactory(repo)}
まだ馴染みがない
Event.ktの部分 Eventの状態を通知できるようにしたい? liveDataを使うため
espressoの部分 test用?
activityは、UIの骨格の設定のみ(navigation含む)
setContent, setNavigationDrawer, setSupportActionBar
fragmentがUI
viewModelScopeの導入
repository以下は、 suspend関数